#include "graphicsview.h"

GraphicsView::GraphicsView(QWidget *parent)
    : QGraphicsView(parent), scene(new QGraphicsScene(this)) {
    setScene(scene); // 将场景设置给视图
    // 设置矩形范围
    this->setSceneRect(0, 0, 598, 267);
    // 设置区域中心
    this->centerOn(this->sceneRect().center());
    this->setBackgroundBrush(QBrush(Qt::black));
    //this->circle_position(100,100,1.2);


}

GraphicsView::~GraphicsView() {
    // 资源清理
}

void GraphicsView::updateCircleSize(int index, double size) {
    if (index < 0 || index >= circles.size()) return;
    QGraphicsEllipseItem *circle = circles.at(index);
    circle->setRect(-size / 2, -size / 2, size, size);
}



void GraphicsView::circle_position(qreal x, qreal y, qreal size)
{
    qDebug()<<"asdfa";
    // 添加圆
    QGraphicsEllipseItem *circle = scene->addEllipse(x, y, 80, 80, QPen(Qt::green), QBrush(Qt::blue));

    // 创建模糊边缘
    QGraphicsBlurEffect *blur = new QGraphicsBlurEffect();
    blur->setBlurRadius(10); //设置模糊半径，根据需要调整值
\
    circle->setGraphicsEffect(blur);// 模糊效果应用于圆
            // 将辉光效果应用到圆上

    circle->setPos(x, y);
    circle->setScale(size);
    circles.append(circle);
}
